package com.springclouddemo.service.system.controller;

import com.springclouddemo.common.Response;

import com.springclouddemo.common.domain.SysSetting;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RequestMapping(value = "/test/")
@RestController
@Api(tags="repo.system | 系统服务")
public class TestController {
    @GetMapping("/say/{name}")
    @ApiOperation(value="say | 打招呼接口")
    public Response<Map<String, Object>> say(@PathVariable("name") String name) {
        Response<Map<String, Object>> response = new Response<>();
        response.setCode("1");
        response.setMsg("获取会员信息成功!");
        //从数据库根据用户查询会员信息
        Map<String, Object> result = new HashMap<>();
        result.put("level", "vip1");
        result.put("username", name);
        response.setResult(result);
        return response;
    }
    @GetMapping("/hello/{name}")
    @ApiOperation(value="hello | 你好接口")
    public String hello(@PathVariable("name") String name) {
        return "hello," + name + "!";
    }

    @GetMapping("/getSetting")
    @ApiOperation(value="setting | 获取配置")
    public Object getSetting() {
        SysSetting setting =new SysSetting();
        setting.setAppName("Spring Cloud Demo");
        setting.setAppValue("Spring Cloud Demo Description");
        System.out.println("测试 setting = " + setting.toString());
        return setting;
    }
}
